# -*- coding: utf-8 -*-
# @Time    : 2023/8/20
# @Author  : Yangyali
#
import playwright
from loguru import logger
from playwright.sync_api import Playwright, expect

from common.util import get_config_value, write_to_yaml


def login(request_context):
    payload={"username":"tester","password":"tester"}
    response=request_context.post('/auth/login',data=payload)
    logger.info(response.text())
    if response.status==200:
        logger.info("登录成功")
        token=response.json()["data"]["token"]
        expect(response).to_be_ok()
        write_to_yaml("token",token)
        return token
    else:
        logger.info("登录失败")

